﻿using System.Windows.Controls;
using System.Windows.Shapes;
using FishSimulation.Model;
using System.Windows.Media;

namespace FishSimulation.Views {
    /// <summary>
    /// Interaction logic for ActorInPondView.xaml
    /// </summary>
    public partial class ActorInPondView : ViewBase {
        #region Properties
        public Actor Actor {
            get {
                if (this.DataContext == null)
                    this.DataContext = new Actor();
                return this.DataContext as Actor;
            }
            set {
                this.DataContext = value;
            }
        }
        #endregion

        #region Constructors
        public ActorInPondView() {
            InitializeComponent();                
        }
        #endregion

        #region Methods
        public override ModelBase GetPropertyGridItem() {
            return this.Actor;
        }

        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) {
            if(this.Actor.ActorType == null)
                Repository.Instance.FillActorType(null, this.Actor);
            Ellipse e = null;
            if (this.Actor.ActorType == null || this.Actor.ActorType.Color == null) {
                e = new Ellipse() { Width = 6, Height = 6, Fill = System.Windows.Media.Brushes.Black };                
            }
            else {
                e = new Ellipse() { Width = 6, Height = 6, Fill = this.Actor.ActorType.Color };
            }
            canvas.Children.Add(e);
        }
        #endregion
    }
}
